﻿using B.W.traceability.Domain.养殖;
using B.W.traceability.ErrorCode;
using B.W.traceability.Infrastructure;
using B.W.traceability.Read.API.Application.APPlicationCommand;
using MediatR;
using System.Collections.Generic;

namespace B.W.traceability.Read.API.Application.APPlicationHanlder
{
    public class TraceabilityHandler : IRequestHandler<TraceabilityCommand, APIResult<List<TraceabilityNames>>>
    {
        private readonly IBInfrastructure<TraceabilityNames> TraceabilityNamesAPIResult;

        public TraceabilityHandler(IBInfrastructure<TraceabilityNames> traceabilityNamesAPIResult)
        {
            TraceabilityNamesAPIResult = traceabilityNamesAPIResult;
        }

        public  Task<APIResult<List<TraceabilityNames>>> Handle(TraceabilityCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<TraceabilityNames>> result = new APIResult<List<TraceabilityNames>>();
            result.Code= ErrorAPIResult.查询成功;
            result.Msg= ErrorAPIResult.查询成功.ToString();
            var list = TraceabilityNamesAPIResult.Query();
            result.Data = list.ToList();
            return  Task.FromResult(result);
        }
    }
}
